var path = require('path')

module.exports = {
  mode: "development",
  entry: {
    "decorator1": "./decorator1.js",
    "decorator2": "./decorator2.js",
    "decorator3-decorator的应用场景": "./decorator3-decorator的应用场景.js",
    "decorator4-模拟生命周期": "./decorator4-模拟生命周期.js",
  },
  output: {
    path: path.resolve(__dirname, "./dist"),
    filename: "[name].js"
  },
  module: {
    rules: [ //webpack 4.X写法
      {
        test: /.js$/,
        use: ['babel-loader']
      }
    ]
  }
}

//操作文件
// fs.readdirSync(__dirname).reduce((entries, dir) => {
//   const fullDir = path.join(__dirname, dir)
//   const entry = path.join(fullDir, 'app.ts')
//   if (fs.statSync(fullDir).isDirectory() && fs.existsSync(entry)) {
//     entries[dir] = ['webpack-hot-middleware/client', entry]
//   }
//   return entries
// }, {})